import { Pipe, PipeTransform } from '@angular/core';

/**
 * 广告代理状态
 * 用户状态：0-待完善资料，1-待审核，2-审核通过，3-审核失败
 * ----------------------------------------------------------------
 */
export const agentStateArrs = [
  { value: 0, label: '待完善资料', color: '#333333' },
  { value: 1, label: '待审核', color: '#FF9900' },
  { value: 2, label: '审核通过', color: '#008000' },
  { value: 3, label: '审核不通过', color: '#FF0000' }
]

@Pipe({ name: 'advertisementStatus' })
export class AdvertisementStatusPipe implements PipeTransform {
  transform(value: any, exponent?: any): any {
    let tmpObj: any = agentStateArrs.find((item: any) => item.value == value);

    if (exponent === 'color') {
      return tmpObj?.color || '#333333';
    } else {
      return tmpObj?.label || '-';
    }
  }
}

/**
 * 广告代理申请状态
 * 审核状态：0-待审核，1-审核通过，2-审核失败，3-已取消
 * ----------------------------------------------------------------
 */
export const agentApplyStateArrs = [
  { value: 0, label: '待审核', color: '#FF9900' },
  { value: 1, label: '审核通过', color: '#008000' },
  { value: 2, label: '审核不通过', color: '#FF0000' },
  { value: 3, label: '已取消', color: '#909399' }
]

@Pipe({ name: 'agentApplyStatus' })
export class AgentApplyStatusPipe implements PipeTransform {
  transform(value: any, exponent?: any): any {
    let tmpObj: any = agentApplyStateArrs.find((item: any) => item.value == value);

    if (exponent === 'color') {
      return tmpObj?.color || '#333333';
    } else {
      return tmpObj?.label || '-';
    }
  }
}

/**
 * 银联商务 拓展员管理 状态
 * 审核状态：0-待完善，1-待审核，2-审核通过，3-审核不通过
 * ----------------------------------------------------------------
 */
 export const unionPayDeveloperStatusArrs = [
  { value: 0, label: '待完善', color: '#606266' },
  { value: 1, label: '待审核', color: '#0D71FF' },
  { value: 2, label: '审核通过', color: '#0E8E41' },
  { value: 3, label: '审核不通过', color: '#FF0000' }
]

@Pipe({ name: 'unionPayDeveloperStatus' })
export class UnionPayDeveloperStatusPipe implements PipeTransform {
  transform(value: any, exponent?: any): any {
    let tmpObj: any = unionPayDeveloperStatusArrs.find((item: any) => item.value == value);

    if (exponent === 'color') {
      return tmpObj?.color || '#333333';
    } else {
      return tmpObj?.label || '-';
    }
  }
}

/**
 * 银联商务 商户管理 状态
 * 审核状态：0-待审核，1-审核通过，2-审核不通过
 * ----------------------------------------------------------------
 */
 export const unionPayMerchantStatusArrs = [
  { value: 0, label: '待审核', color: '#0D71FF' },
  { value: 1, label: '审核通过', color: '#0E8E41' },
  { value: 2, label: '审核不通过', color: '#FF0000' }
]

@Pipe({ name: 'unionPayMerchantStatus' })
export class UnionPayMerchantStatusPipe implements PipeTransform {
  transform(value: any, exponent?: any): any {
    let tmpObj: any = unionPayMerchantStatusArrs.find((item: any) => item.value == value);

    if (exponent === 'color') {
      return tmpObj?.color || '#333333';
    } else {
      return tmpObj?.label || '-';
    }
  }
}

